<!--
* @FileDescription: 固定报表
* @Author: yuec621@outlook.com
* @Date: 2025-04-08 16:15:22
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2025-09-23 16:22:08
-->
<template>
  <div class="pagestyle">
    <!-- 打印内容 -->
    <div id="printContent" ref="printContent" class="print-content" v-show="false">
      <div class="tophtml page-header" style="width: 100%;">
        <div style="text-align: center;font-weight: 600;font-size: 24px;">
          {{state.formData.titleName?state.formData.titleName:state.leftLabelType}}
          {{state.querysList[0].binddata==1?'月报表':
  state.querysList[0].binddata==3?'日报表':'班次报表'
  }}</div>
        <div style="display: flex;justify-content: space-between;">
          <span>打印时间: {{dayjs().format('YYYY/MM/DD hh:mm:ss')}}</span>
          <span>时间范围: {{state.rangeTime.dataValue[0]}}至{{state.rangeTime.dataValue[1]}}</span>
        </div>
      </div>
      <!-- 第一个表格 -->
      <div class="table-section" v-for="(item,indexF) in state.rightList">
        <p>{{indexF==0? state.leftLabelType+'统计信息' :state.leftLabelType+'详细信息'}}:</p>
        <table class="print-table">
          <thead style="border: 1px solid #ddd;">
            <tr style="border: 1px solid #ddd;">
              <th v-for="col in item.tableheads" :key="col.field">{{ col.title }}</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="(row, index) in item.tableData" :key="index">
              <td v-for="col in item.tableheads" :key="col.field">{{ row[col.field] }}</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <el-row :gutter="20" style="height: 100%;">
      <el-col :span="3" style="height: 100%;">
        <div class="leftBox" style="height: 100%;" :style="{background:isDark?'rgba(255, 255, 255, 0.8)':''}">
          <el-input style="margin: 11px 0;" v-model="state.inputSearch" placeholder="请输入" @blur="inputSearchBlur">
            <template #suffix>
              <el-icon>
                <search />
              </el-icon>
            </template>
          </el-input>
          <div class="leftmenuList">
            <div class="leftLabel" :class="state.leftLabelType==item.label?'active':''" @click="leftClick(item)"
              v-for="item in state.leftmenuList" :key="item.label">
              {{ item.label }}
            </div>
          </div>
        </div>
      </el-col>
      <el-col :span="21" style="height: 100%;">
        <div style="height: 100%;">
          <div ref="queryboxH" class="querybox" style="width: 100%; border-radius: 8px 8px 0 0;"
            :style="{background:isDark?'rgba(255, 255, 255, 0.8)':''}">
            <querybox style="width: 100%;" :queryList="state.querysList" @query="query">
            </querybox>
          </div>
          <div ref="tableBoxH" class="tableBox" :style="{background:isDark?'rgba(255, 255, 255, 0.8)':'',
          height: state.tableBoxHeight}" style="overflow-y: auto;">
            <p class="tableBoxT">
              <span class="biao">固定报表</span>
              <span class="span"> <span :class="
                          state.listBtnType == 1 ? 'listInfoBtn active' : 'listInfoBtn'
                        " @click="listInfoBtnClick(1)">
                  <svg-icon :class="state.listBtnType == 1 ? 'active' : ''" class-name="search-icon"
                    icon-class="dayin" />
                  打印
                </span>
                <span ref="listBtnTypeshezhi" :class="
                          state.listBtnType == 2 ? 'listInfoBtn active' : 'listInfoBtn'
                        " @click="listInfoBtnClick(2)">
                  <svg-icon :class="state.listBtnType == 2 ? 'active' : ''" class-name="search-icon"
                    icon-class="shezhi" />
                  报表设置
                </span>
                <span :class="
                          state.listBtnType == 3 ? 'listInfoBtn active' : 'listInfoBtn'
                        " @click="listInfoBtnClick(3)">
                  <svg-icon :class="state.listBtnType == 3 ? 'active' : ''" class-name="search-icon"
                    icon-class="xiazai" />
                  下载
                </span></span>
            </p>
            <configFixedCom id="configFixedCom" :formConfig="state.formData" :searchObj="state.searchObj"
              :configFixedComprint="state.configFixedComprint" style="margin:10px" v-if="state.leftLabelType=='配置报表'"
              v-loading="state.loading" @configReportChange="configReportChange">
            </configFixedCom>

            <div id="printContainer" v-else style="overflow-y: auto;">
              <div v-for="(itemF,indexF) in state.rightList">
                <vxe-table :scroll-y="{enabled: true, gt: 100}" :loading="state['torightLoading'+indexF]"
                  style="margin-top: 10px;" :data="itemF.tableData"
                  :height="indexF==0&&state.rightList.length>1?'100':'400'" ref="xGrid" stripe border="inner"
                  :key="itemF.tableData">
                  <vxe-column type="seq" :width="55" title="序号"></vxe-column>
                  <vxe-column v-for="(item, index) in itemF.tableheads" :field="item.field" :title="item.title"
                    :width="item.width" :params="{ name: item.name }" :key="index">
                    <template #default="{ row }">
                      {{ row[item.field]==null?'-':row[item.field] }}
                    </template>
                  </vxe-column>
                </vxe-table>
              </div>
            </div>
          </div>
        </div>
        <!-- 报表设置 -->
        <div v-if="state.addModal" class="reportSetBox" :style="{position: 'absolute',left:state.xydata.x+'px',
                top:state.xydata.y+'px',zIndex:100}">
          <el-form ref="formRef" :model="state.formData" :rules="state.rules" label-position="left">
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="标题内容">
                  <el-input v-model="state.formData.titleName">
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="标题字体">
                  <el-select class="w100" v-model="state.formData.titleTypeface" clearable placeholder="请选择">
                    <el-option v-for="itemsub in ['微软雅黑']" :key="itemsub" :label="itemsub" :value="itemsub">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="显示签名栏边框">
                  <el-switch v-model="state.formData.showBorder">
                  </el-switch>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="显示打印人员">
                  <el-switch v-model="state.formData.showPersonnel">
                  </el-switch>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="显示原因分析">
                  <el-switch v-model="state.formData.showReason" @change="showReasonChange">
                  </el-switch>
                </el-form-item>
              </el-col>
              <el-col :span="12" v-for="(item,index) in ['One','Two','Three','Four','Five','Six']">
                <el-form-item :label="'标名'+(index+1)">
                  <el-select class="w100" v-model="state.formData['title'+item]" clearable placeholder="请选择">
                    <el-option v-for="itemsub in ['无','矿长','总工','队长']" :key="itemsub" :label="itemsub" :value="itemsub">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="24" style="text-align: right;margin-top: 10px;">
                <el-button type="info" @click="cancelClick">取消</el-button>
                <el-button type="primary" @click="settingClick">确定</el-button>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script setup>
  import axios from "@/utils/request";
  import {
    computed,
    nextTick,
    onMounted,
    reactive
  } from "vue";
  import querybox from "@/components/commonCom/querybox";
  import configFixedCom from "./com/configFixedCom";
  import {
    table_headers
  } from "@/components/commonCom/table_headers";
  import dayjs from "dayjs";
  import useSettingsStore from '@/store/modules/settings'
  const settingsStore = useSettingsStore()
  const isDark = computed(() => settingsStore.isDark);
  import {
    searchareaTree,
    getlistSensorName
  } from "@/api/config";
  import VXETable from 'vxe-table'
  import * as XLSX from 'xlsx';
  import {
    saveAs
  } from 'file-saver'
  const xGrid = ref()
  const {
    proxy
  } = getCurrentInstance();
  let state = reactive({
    fenyeShow: true,
    topHtml: '',
    bottomHtml: '',
    inputSearch: '',
    // 报表设置的属性
    addModal: false,
    formData: {},
    rules: {},
    // 列表顶部按钮
    listBtnType: undefined,
    querysList: [{
        fieldsearch: "conditionType",
        isReport: true,
        field: "conditionType",
        title: "报表类型",
        type: "radiospecial",
        binddata: 1,
        options: [{
            label: "月报表",
            value: 1,
          },
          {
            label: "日报表",
            value: 3,
          },
          {
            label: "班次查询",
            value: 2,
          },
        ],
        col: 12
      },
      {
        field: "datetime",
        title: "报表时间",
        type: "datamonth", //datetime
        isReport: true,
        binddata: dayjs().format('YYYY-MM-DD'),
        col: 12
      },
      {
        fieldsearch: "banci",
        field: "banci",
        title: "班次选择",
        type: "selectspecial",
        binddata: "",
        options: [],
        typespecial: 1,
        show: true,
        col: 12
      },
      {
        field: "area",
        title: "所在区域",
        type: "cascaderRadionarmal",
        binddata: "",
        options: [],
        isReport: true,
        props: {
          children: "childList",
          value: "areaName",
          label: "areaName",
          checkStrictly: true,
          emitPath: false,
        },
        col: 12
      },
      {
        field: "condition",
        title: "测点类型",
        type: "cascaderRadionarmal",
        binddata: "A",
        options: [],
        isReport: true,
        props: {
          children: "children",
          value: "code",
          label: "name",
          emitPath: false,
        },
        col: 12
      },

      {
        field: 'pointId',
        title: "选择测点",
        type: "cascaderRadionarmal",
        binddata: "",
        options: [],
        isReport: true,
        props: {
          children: "children",
          value: "commonField",
          label: "commonField",
          emitPath: false,
        },
        col: 12
      },

      {
        field: "reasen",
        title: "原因分析",
        isReport: true,
        type: "switch",
        binddata: false,
        col: 6
      }
    ],
    querys: [{
        fieldsearch: "conditionType",
        field: "conditionType",
        title: "报表类型",
        type: "radiospecial",
        binddata: 1,
        options: [{
            label: "月报表",
            value: 1,
          },
          {
            label: "日报表",
            value: 3,
          },
          {
            label: "班次查询",
            value: 2,
          },
        ],
        col: 12
      },
      {
        field: "datetime",
        title: "报表时间",
        type: "datamonth", //datetime
        isReport: true,
        binddata: dayjs().format('YYYY-MM-DD'),
        col: 12
      },


      {
        fieldsearch: "banci",
        field: "banci",
        title: "班次选择",
        type: "selectspecial",
        binddata: "",
        options: [],
        typespecial: 1,
        show: true,
        col: 12
      },
      {
        field: "area",
        title: "所在区域",
        type: "cascaderRadionarmal",
        binddata: "",
        options: [],
        isReport: true,
        props: {
          children: "childList",
          value: "areaName",
          label: "areaName",
          checkStrictly: true,
          emitPath: false,
        },
        col: 12
      },
      {
        field: "condition",
        title: "测点类型",
        type: "cascaderRadionarmal",
        binddata: "A",
        options: [],
        isReport: true,
        props: {
          children: "children",
          value: "code",
          label: "name",
          emitPath: false,
        },
        col: 12
      },
      {
        field: 'pointIds',
        title: "选择测点",
        type: "cascaderRadionarmal",
        binddata: [],
        options: [],
        isReport: true,
        props: {
          children: "children",
          value: "commonField",
          label: "commonField",
          emitPath: false,
          multiple: true
        },
        col: 12
      },

      {
        field: "reasen",
        title: "原因分析",
        isReport: true,
        type: "switch",
        binddata: false,
        col: 6
      }
    ],
    xydata: {
      x: 0,
      y: 0
    },
    leftmenuList: [{
        label: '报警',
        rangeTime: ["alarmStartTime", "endTime"],
        tableList: [{
            tableheads: computed(() => table_headers.hisPointSimulateStatistic), //模拟量
            tableheadstwo: 'hisPointSwitchStatistic',
            tableheadsone: 'hisPointSimulateStatistic',
            dataUrl: "/hisPointAlarm/listSimulateAlarmPoints",
          },
          {
            tableheads: computed(() => table_headers.hisPointSimulateDetail),
            tableheadstwo: 'hisPointSwitchDetail',
            tableheadsone: 'hisPointSimulateDetail',
            dataUrl: "/hisPointAlarm/getSimulatePointByPointId",
          }
        ],
      }, {
        label: '断电',
        rangeTime: ["cutStartTime", "cutEndTime"],
        tableList: [{
            tableheads: computed(() => table_headers.hisPointCutSimulateStatistic), //模拟量
            tableheadstwo: 'hisPointCutSwitchStatistic',
            tableheadsone: 'hisPointCutSimulateStatistic', //模拟量
            dataUrl: "/hisPointCut/listPointCuts",
          },
          {
            tableheads: computed(() => table_headers.hisPointCutSimulateDetail), //开关量 
            tableheadstwo: 'hisPointCutSwitchDetail',
            tableheadsone: 'hisPointCutSimulateDetail', //开关量 
            dataUrl: "/hisPointCut/getCutPointByPointId",
          }
        ]
      }, {
        label: '馈电异常',
        rangeTime: ["feedStartTime", "feedEndTime"],
        tableList: [{
            tableheads: computed(() => table_headers.hisPointFeed), //模拟量
            dataUrl: "/hisPointFeed/listHisFeedPoints",
          },
          {
            tableheads: computed(() => table_headers.hisPointDetailFeed),
            dataUrl: "/hisPointFeed/listHisFeedDetailPoints",
          }
        ]
      }, {
        label: '模拟量历史数据',
        rangeTime: ["startTime", "endTime"],
        tableList: [{
            tableheads: computed(() => table_headers.hisHourInfo), //模拟量
            dataUrl: "/hisPointHour/listTimeInfo",
          },
          {
            tableheads: computed(() => table_headers.hisHourFixReportDetail),
            dataUrl: "/hisPointHour/listFixReportTimeInfo",
          }
        ],
        querys: [{
            fieldsearch: "conditionType",
            field: "conditionType",
            title: "报表类型",
            type: "radiospecial",
            binddata: 1,
            options: [{
                label: "月报表",
                value: 1,
              },
              {
                label: "日报表",
                value: 3,
              },
              {
                label: "班次查询",
                value: 2,
              },
            ],
            col: 12
          },
          {
            field: "datetime",
            title: "报表时间",
            type: "datamonth", //datetime
            isReport: true,
            binddata: dayjs().format('YYYY-MM-DD'),
            col: 12
          },


          {
            fieldsearch: "banci",
            field: "banci",
            title: "班次选择",
            type: "selectspecial",
            binddata: "",
            options: [],
            typespecial: 1,
            show: true,
            col: 12
          },
          {
            field: "area",
            title: "所在区域",
            type: "cascaderRadionarmal",
            binddata: "",
            options: [],
            isReport: true,
            props: {
              children: "childList",
              value: "areaName",
              label: "areaName",
              checkStrictly: true,
              emitPath: false,
            },
            col: 12
          },
          {
            field: "condition",
            title: "测点类型",
            type: "cascaderRadionarmal",
            binddata: "A",
            options: [],
            isReport: true,
            props: {
              children: "children",
              value: "code",
              label: "name",
              emitPath: false,
            },
            col: 12
          },
          {
            field: 'pointIds',
            title: "选择测点",
            type: "cascaderRadionarmal",
            binddata: "",
            options: [],
            isReport: true,
            props: {
              children: "children",
              value: "commonField",
              label: "commonField",
              // checkStrictly: true,
              emitPath: false,
              multiple: true
            },
            col: 12
          }

        ],

      }, {
        label: '开关量历史变动',
        rangeTime: ["startTime", "endTime"],
        tableList: [{
            tableheads: computed(() => table_headers.hisSwitchStatistic), //模拟量
            dataUrl: "/hisPointSwitch/listHisSwitch",
          },
          {
            tableheads: computed(() => table_headers.hisSwitchDetail),
            dataUrl: "/hisPointSwitch/listDetailSwitch",
          }
        ],
        querys: [{
            fieldsearch: "conditionType",
            field: "conditionType",
            title: "报表类型",
            type: "radiospecial",
            binddata: 1,
            options: [{
                label: "月报表",
                value: 1,
              },
              {
                label: "日报表",
                value: 3,
              },
              {
                label: "班次查询",
                value: 2,
              },
            ],
            col: 12
          },
          {
            field: "datetime",
            title: "报表时间",
            type: "datamonth", //datetime
            isReport: true,
            binddata: dayjs().format('YYYY-MM-DD'),
            col: 12
          },


          {
            fieldsearch: "banci",
            field: "banci",
            title: "班次选择",
            type: "selectspecial",
            binddata: "",
            options: [],
            typespecial: 1,
            show: true,
            col: 12
          },
          {
            field: "area",
            title: "所在区域",
            type: "cascaderRadionarmal",
            binddata: "",
            options: [],
            isReport: true,
            props: {
              children: "childList",
              value: "areaName",
              label: "areaName",
              checkStrictly: true,
              emitPath: false,
            },
            col: 12
          },
          {
            field: "condition",
            title: "测点类型",
            type: "cascaderRadionarmal",
            binddata: "D",
            options: [],
            isReport: true,
            props: {
              children: "children",
              value: "code",
              label: "name",
              emitPath: false,
            },
            col: 12
          },
          {
            field: 'pointIds',
            title: "选择测点",
            type: "cascaderRadionarmal",
            binddata: "",
            options: [],
            isReport: true,
            props: {
              children: "children",
              value: "commonField",
              label: "commonField",
              // checkStrictly: true,
              emitPath: false,
              multiple: true
            },
            col: 12
          }

        ],
      }, {
        label: '历史标校报表',
        rangeTime: ["calibrationStartTime", "calibrationEndTime"],
        tableList: [{
          tableheads: computed(() => table_headers.hisPointCalibration), //模拟量
          dataUrl: "/hisPointCalibration/listHisPointCalibration"
        }]
      },
      {
        label: '历史传感器故障',
        rangeTime: ["faultStartTime", "faultEndTime"],
        tableList: [{
            tableheads: computed(() => table_headers.hisFaultPoint), //模拟量
            dataUrl: "/hisPointFault/listHisPointFeedDTO"
          },
          {
            tableheads: computed(() => table_headers.hisFaultPointDetail), //模拟量
            dataUrl: "/hisPointFault/listHisDetailPointDTO"
          }
        ]
      },
      {
        label: '设备故障',
        rangeTime: ["faultStartTime", "faultEndTime"],
        tableList: [{
            tableheads: computed(() => table_headers.hisStationFault),
            tableheadstwo: 'hisNetworkFault', //网络故障
            tableheadsone: 'hisStationFault', //分站故障
            tableheadsthree: 'hisFaultPoint', //传感器故障
            tableheadsfour: 'stationFluctuation', //
            dataUrl: "/hisStation/fault/listHisStationFault",
            dataUrlOT: "/hisStation/fault/listHisStationFault",
            dataUrlthree: "/hisPointFault/listHisPointFeedDTO",
          },
          {
            tableheads: computed(() => table_headers.hisStationFaultDetail),
            tableheadstwo: 'hisNetworkFaultDetail',
            tableheadsone: 'hisStationFaultDetail',
            tableheadsthree: 'hisFaultPointDetail',
            tableheadsfour: 'stationFluctuationDetail',
            dataUrl: "/hisStation/fault/listDetailHisStationFault",
            dataUrlOT: "/hisStation/fault/listDetailHisStationFault",
            dataUrlthree: "/hisPointFault/listHisDetailPointDTO",
          }
        ],
        querys: [{
            fieldsearch: "conditionType",
            field: "conditionType",
            title: "报表类型",
            type: "radiospecial",
            binddata: 1,
            options: [{
                label: "月报表",
                value: 1,
              },
              {
                label: "日报表",
                value: 3,
              },
              {
                label: "班次查询",
                value: 2,
              },
            ],
            col: 12
          },
          {
            field: "datetime",
            title: "报表时间",
            type: "datamonth", //datetime
            isReport: true,
            binddata: dayjs().format('YYYY-MM-DD'),
            col: 12
          },


          {
            fieldsearch: "banci",
            field: "banci",
            title: "班次选择",
            type: "selectspecial",
            binddata: "",
            options: [],
            typespecial: 1,
            show: true,
            col: 12
          },
          {
            field: "area",
            title: "所在区域",
            type: "cascaderRadionarmal",
            binddata: "",
            options: [],
            isReport: true,
            props: {
              children: "childList",
              value: "areaName",
              label: "areaName",
              checkStrictly: true,
              emitPath: false,
            },
            col: 12
          },
          {
            field: "stationStatus",
            title: "故障类型",
            type: "cascaderRadionarmal",
            binddata: 2,
            isReport: true,
            props: {
              children: "children",
              emitPath: false,
            },
            options: [{
                label: "分站故障",
                value: 2,
              },
              {
                label: "网络故障",
                value: 4,
              },
              {
                label: "传感器故障",
                value: 6,
              },
              {
                label: "设备故障",
                value: 8,
              },
            ],
            col: 12
          },
          {
            field: 'stationCodesub',
            title: "选择分站",
            type: "cascaderRadionarmal",
            binddata: "",
            options: [],
            props: {
              children: "children",
              value: "commonField",
              label: "commonField",
              checkStrictly: true,
              emitPath: false,
            },
            col: 12
          }
        ]
      },
      {
        label: '历史组合报警报表',
        rangeTime: ["startTime", "endTime"],
        tableList: [{
            tableheads: computed(() => table_headers.hisAssortedCall), //模拟量
            dataUrl: "/HisAssortedCall/listHisAssortedCall"
          },
          {
            tableheads: computed(() => table_headers.hisAssortedCallDetail), //模拟量
            dataUrl: "/HisAssortedCall/listHisAssortedCallDetail"
          }
        ],
        querys: [{
            fieldsearch: "conditionType",
            field: "conditionType",
            title: "报表类型",
            type: "radiospecial",
            binddata: 1,
            options: [{
                label: "月报表",
                value: 1,
              },
              {
                label: "日报表",
                value: 3,
              },
              {
                label: "班次查询",
                value: 2,
              },
            ],
            col: 12
          },
          {
            field: "datetime",
            title: "报表时间",
            type: "datamonth", //datetime
            isReport: true,
            binddata: dayjs().format('YYYY-MM-DD'),
            col: 12
          },


          {
            fieldsearch: "banci",
            field: "banci",
            title: "班次选择",
            type: "selectspecial",
            binddata: "",
            options: [],
            typespecial: 1,
            show: true,
            col: 12
          },
          {
            field: "assortedCallName",
            title: "组合名称",
            type: "select",
            binddata: "",
            options: [],
            col: 12
          },
        ]
      }, {
        label: '历史组合断电报表',
        rangeTime: ["startTime", "endTime"],
        tableList: [{
            tableheads: computed(() => table_headers.hisAssortedBreak), //模拟量
            dataUrl: "/hisAssortedBreak/listHisAssortedBreak"
          },
          {
            tableheads: computed(() => table_headers.hisAssortedBreakDetail), //模拟量
            dataUrl: "/hisAssortedBreak/listHisAssortedBreakDetail"
          }
        ],
        querys: [{
            fieldsearch: "conditionType",
            field: "conditionType",
            title: "报表类型",
            type: "radiospecial",
            binddata: 1,
            options: [{
                label: "月报表",
                value: 1,
              },
              {
                label: "日报表",
                value: 3,
              },
              {
                label: "班次查询",
                value: 2,
              },
            ],
            col: 12
          },
          {
            field: "datetime",
            title: "报表时间",
            type: "datamonth", //datetime
            isReport: true,
            binddata: dayjs().format('YYYY-MM-DD'),
            col: 12
          },


          {
            fieldsearch: "banci",
            field: "banci",
            title: "班次选择",
            type: "selectspecial",
            binddata: "",
            options: [],
            typespecial: 1,
            show: true,
            col: 12
          },
          {
            field: "assortedBreakName",
            title: "组合名称",
            type: "select",
            binddata: "",
            options: [],
            col: 12
          },
        ]
      },
      {
        label: '历史组合累计计时报表',
        rangeTime: ["startTime", "endTime"],
        tableList: [{
            tableheads: computed(() => table_headers.hisAssortedAccumulation), //模拟量
            dataUrl: "/hisAssortedAccumulation/list"
          },
          {
            tableheads: computed(() => table_headers.hisAssortedAccumulationDetail), //模拟量
            dataUrl: "/hisAssortedAccumulation/listDetails"
          }
        ],
        querys: [{
            fieldsearch: "conditionType",
            field: "conditionType",
            title: "报表类型",
            type: "radiospecial",
            binddata: 1,
            options: [{
                label: "月报表",
                value: 1,
              },
              {
                label: "日报表",
                value: 3,
              },
              {
                label: "班次查询",
                value: 2,
              },
            ],
            col: 12
          },
          {
            field: "datetime",
            title: "报表时间",
            type: "datamonth", //datetime
            isReport: true,
            binddata: dayjs().format('YYYY-MM-DD'),
            col: 12
          },
          {
            fieldsearch: "banci",
            field: "banci",
            title: "班次选择",
            type: "selectspecial",
            binddata: "",
            options: [],
            typespecial: 1,
            show: true,
            col: 12
          },
          {
            field: "assortedAccumulationName",
            title: "组合累计计时名称",
            type: "select",
            binddata: "",
            options: [],
            col: 12
          },
        ]
      },
      {
        label: '历史充放电报表',
        rangeTime: ["startTime", "endTime"],
        tableList: [{
          tableheads: computed(() => table_headers.hisPowerCharge), //模拟量
          dataUrl: "/hisPowerCharge/attainPowerCharges"
        }],
        querys: [{
            fieldsearch: "conditionType",
            field: "conditionType",
            title: "报表类型",
            type: "radiospecial",
            binddata: 1,
            options: [{
                label: "月报表",
                value: 1,
              },
              {
                label: "日报表",
                value: 3,
              },
              {
                label: "班次查询",
                value: 2,
              },
            ],
            col: 12
          },
          {
            field: "datetime",
            title: "报表时间",
            type: "datamonth", //datetime
            isReport: true,
            binddata: dayjs().format('YYYY-MM-DD'),
            col: 12
          },
          {
            fieldsearch: "banci",
            field: "banci",
            title: "班次选择",
            type: "selectspecial",
            binddata: "",
            options: [],
            typespecial: 1,
            show: true,
            col: 12
          },
          {
            field: "powerName",
            title: "电源名称",
            type: "select",
            binddata: "",
            options: [],
            col: 12
          },
          {
            field: "chargeType",
            title: "充放电类型",
            type: "select",
            binddata: "",
            options: [{
              label: '充电',
              value: '充电'
            }, {
              label: '放电',
              value: '放电'
            }],
            col: 12
          },
        ]
      },
      {
        label: '累计量报表',
        rangeTime: ["startTime", "endTime"],
        tableList: [{
          tableheads: computed(() => table_headers.fixReportAddStatistic), //模拟量
          dataUrl: "/fixReport/gainAddStatistic"
        },{
          tableheads: computed(() => table_headers.fixReportAddDetail), //模拟量
          dataUrl: "/fixReport/gainAddDetail"
        }],
         querys: [{
            fieldsearch: "conditionType",
            field: "conditionType",
            title: "报表类型",
            type: "radiospecial",
            binddata: 1,
            options: [{
                label: "月报表",
                value: 1,
              },
              {
                label: "日报表",
                value: 3,
              },
              {
                label: "班次查询",
                value: 2,
              },
            ],
            col: 12
          },
          {
            field: "datetime",
            title: "报表时间",
            type: "datamonth", //datetime
            isReport: true,
            binddata: dayjs().format('YYYY-MM-DD'),
            col: 12
          },


          {
            fieldsearch: "banci",
            field: "banci",
            title: "班次选择",
            type: "selectspecial",
            binddata: "",
            options: [],
            typespecial: 1,
            show: true,
            col: 12
          },
          {
            field: "area",
            title: "所在区域",
            type: "cascaderRadionarmal",
            binddata: "",
            options: [],
            isReport: true,
            props: {
              children: "childList",
              value: "areaName",
              label: "areaName",
              checkStrictly: true,
              emitPath: false,
            },
            col: 12
          },
          {
            field: "condition",
            title: "测点类型",
            type: "cascaderRadionarmal",
            binddata: "D",
            options: [],
            isReport: true,
            props: {
              children: "children",
              value: "code",
              label: "name",
              emitPath: false,
            },
            col: 12
          },
          {
            field: 'pointIds',
            title: "选择测点",
            type: "cascaderRadionarmal",
            binddata: "",
            options: [],
            isReport: true,
            props: {
              children: "children",
              value: "commonField",
              label: "commonField",
              // checkStrictly: true,
              emitPath: false,
              multiple: true
            },
            col: 12
          },
             {
            field: "fixReportAddInfo",
            title: "是否当前测点",
            type: "elcheckbox",
            binddata: true,
            col: 2
          }

        ],
      },
      {
        label: '输出设备',
        rangeTime: ["startTime", "endTime"],
        tableList: [{
            tableheads: computed(() => table_headers.fixReportOutputDeviceStatistic), //模拟量
            dataUrl: "/fixReport/gainDeviceStatistic",
          },
          {
            tableheads: computed(() => table_headers.fixReportOutputDeviceDetail),
            dataUrl: "/fixReport/gainDeviceDetail",
          }
        ],
        querys: [{
            fieldsearch: "conditionType",
            field: "conditionType",
            title: "报表类型",
            type: "radiospecial",
            binddata: 1,
            options: [{
                label: "月报表",
                value: 1,
              },
              {
                label: "日报表",
                value: 3,
              },
              {
                label: "班次查询",
                value: 2,
              },
            ],
            col: 12
          },
          {
            field: "datetime",
            title: "报表时间",
            type: "datamonth", //datetime
            isReport: true,
            binddata: dayjs().format('YYYY-MM-DD'),
            col: 12
          },

          {
            fieldsearch: "banci",
            field: "banci",
            title: "班次选择",
            type: "selectspecial",
            binddata: "",
            options: [],
            typespecial: 1,
            show: true,
            col: 12
          },

          {
            field: 'pointIds',
            title: "选择开出口",
            type: "cascaderRadionarmal",
            binddata: "",
            options: [],
            props: {
              children: "children",
              value: "commonField",
              label: "commonField",
              // checkStrictly: true,
              multiple: true,
              emitPath: false,
            },
          },
          

        ],

      },
      {
        label: '配置报表',
        querys: [{
            field: 'identifyingNo',
            title: '出厂编号',
            type: 'input',
            binddata: ''
          },
          {
            field: "sensorNameList",
            title: "设备名称",
            type: "cascader",
            binddata: [],
            options: [],
            cascader_props: {
              children: "children",
              value: "name",
              label: "name",
              emitPath: false,
              multiple: true
            },
          },
          {
            field: 'stationCode',
            title: '选择分站',
            type: 'input',
            binddata: '',
            col: 4
          },
          {
            field: "isPower",
            title: "智能电源",
            type: "elcheckbox",
            binddata: true,
            col: 2
          }
        ]
      },
    ],
    leftLabelType: undefined,
    rangeTime: {
      field: [],
      dataValue: ['', '']
    }, //获取相应的页面时间范围字段
    torightLoading0: false,
    torightLoading1: false,
    torightLoading2: false,
    torightLoading3: false,
    loading: false,
    rightList: [],
    torightList: [],
    banciList: [],
    classObj: {},
    searchObj: {},
    printlist: [],
    stationList: [],
    areaObj: {},
    leftmenuListAc: [], //用于搜索还原左侧列表
    tableBoxHeight: 630
  })

  function getqueryboxH() {
    state.tableBoxHeight=600 
    nextTick(() => {
      let h=160 + proxy.$refs['queryboxH'].getBoundingClientRect().height
      state.tableBoxHeight ="calc(100vh - " + h + "px)"; 
      console.log(state.tableBoxHeight,"state.tableBoxHeight")
    })
  }
  getqueryboxH()
  // 分页数据
  function getTableList(url, index) {
    state['torightLoading' + index] = true
    return new Promise((resolve, reject) => {
      axios.post(url, state.searchObj).then(res => {
        state['torightLoading' + index] = false
        resolve(res.data)
      })
    })
  }

  // 表格上方按钮事件
  async function listInfoBtnClick(type) {
    if (type == 1) {
      if (state.leftLabelType == '配置报表') {
        state.configFixedComprint = dayjs().unix()
      } else {
        if (state.rightList.length > 0) {
          await handlePrint()
        } else {
          proxy.$modal.msgWarning('请先查询所要打印的报表!');
        }
      }
    }
    if (type == 2) {
      nextTick(() => {
        if (state.leftLabelType) {
          state.formData.titleName = state.leftLabelType
          state.addModal = !state.addModal
          state.xydata.x = proxy.$refs['listBtnTypeshezhi'].offsetLeft - 400
          state.xydata.y = proxy.$refs['listBtnTypeshezhi'].offsetTop + 30
          getByNameData()
        } else {
          proxy.$modal.msgWarning('请先选择所要设置的报表!');
        }
      })
    }
    if (type == 3) {
      if (xGrid.value.length == 1) {
        xGrid.value[0].exportData({
          filename: state.leftLabelType,
          sheetName: state.leftLabelType,
          type: "xlsx",
          data: xGrid.value[0].getTableData().tableData,
        });
      } else if (xGrid.value.length == 2) {
        // 获取两个表格的数据和列信息
        const table1Data = xGrid.value[0].getTableData().tableData
        const table1Columns = xGrid.value[0].getColumns()
        const table2Data = xGrid.value[1].getTableData().tableData
        const table2Columns = xGrid.value[1].getColumns()
        // 创建工作簿
        const wb = XLSX.utils.book_new()
        // 处理第一个表格数据
        const table1Header = table1Columns.map(column => column.title)
        const table1Rows = table1Data.map(row => {
          return table1Columns.map(column => row[column.field])
        })
        const table1SheetData = [table1Header, ...table1Rows]
        const table1Sheet = XLSX.utils.aoa_to_sheet(table1SheetData)

        // 处理第二个表格数据
        const table2Header = table2Columns.map(column => column.title)
        const table2Rows = table2Data.map(row => {
          return table2Columns.map(column => row[column.field])
        })
        const table2SheetData = [table2Header, ...table2Rows]
        const table2Sheet = XLSX.utils.aoa_to_sheet(table2SheetData)

        // 将工作表添加到工作簿
        XLSX.utils.book_append_sheet(wb, table1Sheet, state.leftLabelType + '统计信息')
        XLSX.utils.book_append_sheet(wb, table2Sheet, state.leftLabelType + '详细信息')
        // 导出Excel文件
        const wbout = XLSX.write(wb, {
          bookType: 'xlsx',
          type: 'array'
        })
        saveAs(new Blob([wbout], {
          type: 'application/octet-stream'
        }), state.leftLabelType + '.xlsx')
      }
    }
  }

  function showReasonChange(val) {
    state.querysList.forEach(item => {
      if (item.field == 'reasen') {
        if (!val) {
          item.type = 'yincang'
        } else {
          item.type = 'switch'
        }
      }
    })
  }

  function getByNameData(itemName) {
    axios.post('fixReport/getByName', {
      itemName: state.leftLabelType
    }).then(res => {
      if (res.data != null) {
        state.formData = res.data
      } else {
        state.formData.titleName = undefined
      }
    })
  }
  // 左侧列表点击事件
  function leftClick(item) {
    state.rightList = []
    state.leftLabelType = item.label
    state.torightList = item.tableList
    state.rangeTime.field = item.rangeTime
    state.searchObj = {}
    if (item.querys) {
      state.querysList = item.querys
      if (item.label == '设备故障') {
        structureList(2)
      }
    } else {
      state.querysList = state.querys
    }
    let stateTime = ''
    if (item.label != '配置报表') {
      state.querysList.forEach(iemss => {
        if (iemss.field == 'condition') {
          state.areaObj.condition = iemss.binddata
        }
        if (iemss.field == 'datetime') {
          stateTime = iemss.binddata
        }
        if (iemss.field != 'conditionType' && iemss.field != 'datetime' && iemss.field != 'stationStatus') {
          iemss.binddata = undefined
        }
      })
      let endVal = dayjs(stateTime).endOf('month').date()
      state.rangeTime.dataValue = [dayjs(stateTime).format('YYYY-MM-01 00:00:00.000'), dayjs(stateTime).format(
        `YYYY-MM-${endVal} 00:00:00.000`)]
      state.querysList[1].type = 'datamonth'
      getSelList()
      getconditionList(state.areaObj)
      let url = ''
      state.querysList.forEach(itemsub => {
        if (item.label == '历史组合报警报表') {
          url = '/HisAssortedCall/getHisAssortedCallNames'
          if (itemsub.field == 'assortedCallName') {
            axios.get(url).then(res => {
              itemsub.options = res.data.map(item => {
                return {
                  label: item,
                  value: item
                }
              })
            })
          }
        } else if (item.label == '历史组合断电报表') {
          url = '/hisAssortedBreak/getHisAssortedBreakNames'
          if (itemsub.field == 'assortedBreakName') {
            axios.get(url).then(res => {
              itemsub.options = res.data.map(item => {
                return {
                  label: item,
                  value: item
                }
              })
            })
          }
        } else if (item.label == '历史组合累计计时报表') {
          url = '/merge/accumulation/getNames'
          if (itemsub.field == 'assortedAccumulationName') {
            axios.get(url).then(res => {
              itemsub.options = res.data.map(item => {
                return {
                  label: item,
                  value: item
                }
              })
            })
          }
        }

      })
    } else {
      state.searchObj = {}
      getlistSensorName({}).then((res) => {
        state.querysList[1].options = res.data;
      });
    }
    nextTick(() => {
      getqueryboxH()
    })

  }
  // 获取分站网络下拉选列表
  function structureList(type) {
    if (type == 6) {
      getconditionList(state.areaObj)
      const newArray = state.querysList.filter(item => item.field !== 'stationCodesub'); // 创建一个不包含id=2的新数组
      state.querysList = newArray
      state.querysList.push({
        field: 'pointId',
        title: "选择测点",
        type: "cascaderRadionarmal",
        binddata: "",
        options: [],
        isReport: true,
        props: {
          children: "children",
          value: "commonField",
          label: "commonField",
          emitPath: false,
        },
        col: 12
      })
    } else if (type == 8) {
      state.querysList.pop()
      const newArray = state.querysList.filter(item => item.field !== 'stationCodesub' && item.field !==
        'pointId'); // 创建一个不包含id=2的新数组
      state.querysList = newArray
    } else {
      const newArray = state.querysList.filter(item => item.field !== 'stationCodesub' && item.field !==
        'pointId'); // 创建一个不包含id=2的新数组
      state.querysList = newArray
      state.querysList.push({
        field: 'stationCodesub',
        title: "选择分站",
        type: "cascaderRadionarmal",
        binddata: "",
        options: [],
        props: {
          children: "children",
          value: "commonField",
          label: "commonField",
          checkStrictly: true,
          emitPath: false,
        },
        col: 12
      })
    }
    axios.post(type == 2 ? "/hisStation/fault/attainStationStructure" :
        '/hisStation/fault/attainIpStructure', state.areaObj)
      .then((res) => {
        state.querysList.forEach((item) => {
          if (type == 2) {
            if (item.field == "stationCodesub") {
              item.title = '选择分站'
              item.options = res.data;
            }
          } else if (type == 4) {
            if (item.field == "stationCodesub") {
              item.title = '选择网络'
              item.options = res.data;
            }
          }
        })
      });
  }
  // 查询按钮触发事件
  async function query(data) {
    if (state.leftLabelType != '配置报表') {
      if (data == 2) {
        state.rightList.forEach(item => {
          item.tableData = []
        })
        state.querysList[0].binddata = 1
        state.querysList[1].type = 'datamonth'
        state.querysList[1].binddata = dayjs().format('YYYY-MM')
      }
      let stateTime = ''
      state.querysList.forEach(iemss => {
        if (iemss.field == 'datetime') {
          stateTime = iemss.binddata
        }
      })
      if (stateTime != null) {
        let endVal = dayjs(stateTime).endOf('month').date()
        if (state.querysList[0].binddata == 3) {
          state.rangeTime.dataValue = [dayjs(stateTime).format('YYYY-MM-DD 00:00:00.000'), dayjs(stateTime)
            .format(
              'YYYY-MM-DD 23:59:59.000')
          ]
        } else if (state.querysList[0].binddata == 1) {
          state.rangeTime.dataValue = [dayjs(stateTime).format('YYYY-MM-01 00:00:00.000'), dayjs(stateTime).format(
            `YYYY-MM-${endVal} 00:00:00.000`)]
        } else {
          state.querysList[1].type = 'datetime'
          state.querysList[1].binddata = dayjs(stateTime).format('YYYY-MM-DD')
        }
      } else {
        state.rangeTime.dataValue = ['', '']
      }
      if (data.type == 'report' && data.item.field == 'conditionType') {
        if (data.val == 2) {
          state.classObj.dateSuffix = dayjs(stateTime).format('YYYY-MM-DD')
          await getsearchAll()
        }
        if (data.val == 1) {
          state.querysList[1].type = 'datamonth'
        }
        if (data.val == 3) {
          state.querysList[1].type = 'datetime'
          state.querysList[1].binddata = dayjs().format('YYYY-MM-DD')
        }
      } else if (data.type == 44 && data.item.field == 'stationStatus') {
        if (data.val1 == 4) {
          state.torightList.forEach(item => {
            if (item.tableheadstwo) {
              setTimeout(() => {
                item.tableheads = computed(() => table_headers[item.tableheadstwo])
                item.dataUrl = item.dataUrlOT
              }, 300)
            }
          })
        } else if (data.val1 == 2) {
          state.torightList.forEach(item => {
            if (item.tableheadsone) {
              setTimeout(() => {
                item.tableheads = computed(() => table_headers[item.tableheadsone])
                item.dataUrl = item.dataUrlOT
              })
            }
          })
        } else if (data.val1 == 6) {
          state.torightList.forEach(item => {
            if (item.tableheadsthree) {
              setTimeout(() => {
                item.tableheads = computed(() => table_headers[item.tableheadsthree])
                item.dataUrl = item.dataUrlthree
              })
            }
          })
        }
        structureList(data.item.binddata)
      } else if (data.type == 44 && data.item.field == 'controlPortType') {
        if (data.val1 == 2) {
          state.torightList.forEach(item => {
            if (item.tableheadstwo) {
              setTimeout(() => {
                item.tableheads = computed(() => table_headers[item.tableheadstwo])
              }, 300)
            }
          })
        } else {
          state.torightList.forEach(item => {
            if (item.tableheadsone) {
              setTimeout(() => {
                item.tableheads = computed(() => table_headers[item.tableheadsone])
              })
            }
          })
        }
        structureList(data.item.binddata)
      } else if (data.type == 44 && data.item.field == 'area') {
        state.areaObj.areaName = data.val1
        getconditionList(state.areaObj)
      } else if (data.type == 44 && data.item.field == 'stationCodesub') {
        data.item.options.forEach(item => {
          if (data.val1 == item.commonField) {
            let data = item.children.map(itemc => {
              return itemc.commonField
            })
            state.searchObj.stationCode = data.join(';')
            delete state.searchObj.stationCodesub
          }
        })
      } else if (data.type == 44 && data.item.field == 'controlPointIdsub') {
        data.item.options.forEach(item => {
          if (data.val1 == item.commonField) {
            let data = item.children.map(itemc => {
              return itemc.commonField
            })
            state.searchObj.controlPointId = data.join(';')
            delete state.searchObj.controlPointIdsub
          }
        })
      } else if (data.type == 44 && data.item.field == 'condition') {
        getconditionList({
          condition: data.val1
        })
        if (data.val1.includes('D') && state.torightList.length > 0) {
          state.torightList.forEach(item => {
            if (item.tableheadstwo) {
              setTimeout(() => {
                item.tableheads = computed(() => table_headers[item.tableheadstwo])
              }, 300)
            }
          })
        } else {
          state.torightList.forEach(item => {
            if (item.tableheadsone) {
              setTimeout(() => {
                item.tableheads = computed(() => table_headers[item.tableheadsone])
              })
            }
          })
        }
      } else if (data.type == 5) {
        if (data.item && data.item.type == 'datetime') {
          state.classObj.dateSuffix = dayjs(data.val1).format('YYYY-MM-DD')
        }
        state.banciList.forEach(item => {
          if (item.id == data.val) {
            state.classObj.classInfo = item
            banciList(state.classObj)
          }
        })
      }
    }
    if (data == 1) {
      state.loading = true
      if (state.rangeTime.field && state.rangeTime.field.length > 0) {
        state.searchObj[state.rangeTime.field[0]] = state.rangeTime.dataValue[0]
        state.searchObj[state.rangeTime.field[1]] = state.rangeTime.dataValue[1]
      }
      state.querysList.forEach(item => {
        state.searchObj[item.field] = item.binddata
      })
      if (state.torightList && state.torightList[1]) {
        if (state.searchObj.reasen) {
          state.torightList[1].tableheads.push({
            field: "templateDto",
            location: null,
            name: state.torightList[1].tableheads[0].name,
            show: 1,
            sort: 0,
            title: "原因",
            type: null,
            width: 172,
          })
        } else {
          nextTick(() => {
            if (state.torightList[1].tableheads[state.torightList[1].tableheads.length - 1].field ==
              'templateDto') {
              state.torightList[1].tableheads.pop();
            }
          })
        }
      }
      // delete state.searchObj.conditionType
      delete state.searchObj.datetime
      delete state.searchObj.reasen
      state.searchObj = {
        ...state.searchObj
      }
      nextTick(() => {
        let pointId = 'no'
        state.querysList.forEach(itemsub => {
          if (itemsub.field == 'pointId') {
            pointId = itemsub.binddata
          }
        })
        if (state.torightList && state.torightList.length > 0) {
          if (state.rangeTime.dataValue[0] == '') {
            proxy.$modal.msgWarning('请选择报表时间!');
          } else if (pointId == '' || pointId == null) {
            proxy.$modal.msgWarning('请选择所要查询的测点!');
          } else {
            state.torightList.forEach(async (item, index) => {
              let data = await getTableList(item.dataUrl, index)
              if (data != null) {
                item.total = data.total
                if (data.list != null) {
                  if (data.list.length > 0) {
                    item.tableData = data.list
                  } else {
                    item.tableData = []
                  }
                } else {
                  item.tableData = []
                }
              } else {
                item.total = 0
                item.tableData = []
              }
            })
            state.rightList = state.torightList
            state.printlist = state.torightList
          }
        } else if (state.leftLabelType != '配置报表') {
          proxy.$modal.msgWarning('请选择所要查询的报表!');
        }
      })
    }
  }

  function configReportChange(val) {
    state.loading = false
  }
  // 获取搜索栏下拉数据
  function getSelList() {
    axios.post("/hisPointFeed/listAllNames", {
      flag: true,
      code:state.leftLabelType=='累计量报表'?'S':state.leftLabelType == '模拟量历史数据'?'A':state.leftLabelType == '开关量历史变动'?'D':''
    }).then((res) => {
      state.querysList.forEach((item) => {
        if (item.field == "condition") {
          item.options = res.data;
        }
      });
    });
    searchareaTree().then((res) => {
      state.querysList.forEach((item) => {
        if (item.field == "area") {
          item.options = res.data;
        }
      });
    });
    axios.post('/power/supply/search', {}).then(res => {
      state.querysList.forEach((item) => {
        if (item.field == "powerName") {
          item.options = res.data.list.map(item => {
            return {
              label: item.powerName,
              value: item.powerName
            }
          })
        }
      })
    })
  }

  function getsearchAll() {
    axios.post("/class/info/searchAll", {}).then(async (res) => {
      state.querysList.forEach(item => {
        if (item.field == 'banci') {
          item.binddata = res.data.list[0].id
          item.options = res.data.list.map(item => {
            return {
              label: item.className,
              value: item.id
            }
          })
        }
      })
      state.banciList = res.data.list;
      state.classObj.classInfo = res.data.list[0]
      await banciList(state.classObj)
    })
  }

  function getconditionList(data) {
    axios.post("/hisPointFeed/conditionList", data).then((res) => {
      state.querysList.forEach((item) => {
        if (item.field == "pointId" || item.field == "pointIds"&&item.title != "选择开出口") {
          item.options = res.data;
        }
      });
    });
    axios
      .get('/control/fault/getFaultList', data)
      .then((res) => {
        state.querysList.forEach((item) => {
          if (item.title == "选择开出口") {
            item.options = res.data;
          }
        });
      });
  }

  function banciList(data) {
    axios.post("/hisPointFeed/handleClassInfo", data).then((res) => {
      state.rangeTime.dataValue = [res.data.feedStartTime + '.000', res.data.feedEndTime + '.000'];
    });
  }
  let stateTimeinint = ''
  state.querysList.forEach(iemss => {
    if (iemss.field == 'datetime') {
      stateTimeinint = iemss.binddata
    }
  })
  let endValinit = dayjs(stateTimeinint).endOf('month').date()
  state.rangeTime.dataValue = [dayjs().format('YYYY-MM-01 00:00:00.000'), dayjs().format(
    `YYYY-MM-${endValinit} 00:00:00.000`)]
  getconditionList(state.areaObj)
  getSelList()

  function settingClick() {
    state.formData.itemName = state.leftLabelType
    axios.post('/fixReport/addFixReport', state.formData).then(res => {
      proxy.$modal.msgSuccess(res.msg);
      state.addModal = false
    })
  }

  function cancelClick() {
    state.addModal = false
  }
  const printContent = ref(null);
  // 打印处理
  const printConfig = ref({
    style: `
    @page {
      size: A4;
      margin: 20mm 10mm;
    }
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;
    }
    .print-container {
      page-break-inside: avoid;
    }
    .header {
      position: fixed;
      top: 0;
      width: 100%;
      text-align: center;
      padding: 10px 0;
    }
    .footer {
      position: fixed;
      bottom: 0;
      width: 100%;
      // text-align: center;
      padding: 8px 0;
      display: flex;justify-content: space-between;
    }
    .table-content {
      padding-top: 0px;
      margin-bottom: 50px;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      margin: 0;
    }
    th, td {
      border: 1px solid #ddd;
      padding: 2px;
      text-align: left;
    }
    th {
      border: 1px solid #ddd;
      // position: sticky;
      // top: 150px; /* 与.header高度匹配 */
    }
    tr {
      border: 1px solid #ddd;
      page-break-inside: avoid;
      page-break-after: auto;
    }
  `,
    beforePrintMethod: ({
      content
    }) => {
      const header = `
      <div class="header">
        <h2>公司名称</h2>
        <p>报表标题 - ${new Date().toLocaleDateString()}</p>
      </div>
    `;

      const footer = `
      <div class="footer" style="${state.formData.showBorder?'border:1px solid #ddd':''}">
         <span>${state.formData.titleOne!=null?state.formData.titleOne+':':''} </span>
        <span>${state.formData.titleTwo!=null?state.formData.titleTwo+':':''} </span>
        <span>${state.formData.titleThree!=null?state.formData.titleThree+':':''} </span>
        <span>${state.formData.titleFour!=null?state.formData.titleFour+':':''} </span>
        <span>${state.formData.titleFive!=null?state.formData.titleFive+':':''} </span>
        <span>${state.formData.titleSix!=null?state.formData.titleSix+':':''} </span>
        <span style="margin-right:50px">制表:</span>
      </div>
    `;

      return `
      <div class="print-container">
        <div class="table-content">${printContent.value.innerHTML}</div>
        ${footer}
      </div>
    `;
    }
  });
  const handlePrint = () => {
    const content = printContent.value.innerHTML;
    // 构建打印页面的HTML
    VXETable.print({
      ...printConfig.value,
      // printMethod: (options) => {
      //   const {  style } = options;
      //   printJS({
      //     printable: content,
      //     type: 'raw-html',
      //     style: style,
      //     header: '自带头部', // 禁用print-js自带的header
      //     footer: '自带尾部', // 禁用print-js自带的footer
      //     scanStyles: false,
      //     targetStyles: ['*']
      //   });
      // }
    })
  };

  function inputSearchBlur(val) {
    if (state.inputSearch != '') {
      const filtered = state.leftmenuList.filter(item =>
        item.label.toLowerCase().includes(state.inputSearch)
      );
      state.leftmenuList = filtered
    } else {
      state.leftmenuList = state.leftmenuListAc
    }
  }
  state.leftmenuListAc = state.leftmenuList
  onMounted(()=>{
    state.tableBoxHeight=600+'px'
  })
</script>
<style lang="scss" scoped>
  .tableBox {
    padding: 16px;
    // height: calc(100% - 160px);
    background: rgba(255, 255, 255, 0.6);
    border-radius: 0 0 8px 8px;

    .tableBoxT {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0;
      margin: 0;

      .biao {
        font-size: 18px;
        font-weight: 700;
      }

      .span {
        display: flex;
        align-items: center;

      }

    }
  }

  .leftBox {
    background: rgba(91, 109, 128, 0.04);
    padding: 8px;
    border-radius: 4px;
    // height: 82vh;
  }

  .reportSetBox {
    padding: 12px;
    max-width: 596px;
    min-width: 400px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0px 2px 20px rgba(91, 109, 128, 0.2);
    backdrop-filter: blur(20px);
  }

  .leftmenuList {
    font-size: 16px;
    font-weight: 400;
    color: rgba(62, 70, 79, 1);
    height: 100%;

    .leftLabel {
      cursor: pointer;
      padding: 6px 0 6px 12px;
      margin-bottom: 8px;

      &.active {
        background-color: rgba(68, 136, 255, 0.08);
        color: rgba(68, 136, 255, 1);
        font-weight: 700;
      }
    }

  }
</style>